<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>4.Map类型转换操作</title>
</head>

<body>
  <script>
    let hd = new Map([['houdunren', '后盾人'], ['hdcms', '开源系统']]);
    //点语法转数组
    console.log([...hd]); //(2) [Array(2), Array(2)]
    console.log([...hd.entries()]);//(2) [Array(2), Array(2)]
    console.log([...hd.keys()]);//(2) ['hdcms', 'houdunren']
    console.log([...hd.values()]);//(2) ['开源系统', '开源教程']
    // 其实使用for of的时候就是在使用 hd.entries() ,把它变成可叠戴对象
    for (const [key, value] of hd) {
      console.log(key, value);
    }
    //转成数组，使用过滤方法
    let newArr = [...hd].filter(item => {
      // return true 保留，false 过滤掉
      return item[1].includes('后盾人');
    });
    console.log(newArr);/*[Array(2)]
    0: (2) ['houdunren', '后盾人']
    length: 1
    [[Prototype]]: Array(0)*/
    let edu = new Map(newArr);
    console.log(edu);//Map(1) {'houdunren' => '后盾人'}

  </script>
</body>

</html>